package org.example;

import org.example.pack1021.DemoA;
import org.example.pack1021.DemoC;
import org.example.pack1022.controller.UserCotroller;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
    public static void a(){
        ApplicationContext bean = new ClassPathXmlApplicationContext("applicationContext.xml");
        System.out.println("------------------------------------");
        Object obj1 = bean.getBean("da1");
        DemoA obj2 = bean.getBean("da1",DemoA.class);
        DemoA obj3 = bean.getBean(DemoA.class);
        System.out.println(obj1);
        System.out.println(obj2);
        System.out.println(obj3);
        System.out.println("------------------------------------");
        Object obj4 = bean.getBean("db");
        System.out.println(obj4);
        System.out.println("------------------------------------");
        Object obj5 = bean.getBean(DemoC.class);
        System.out.println(obj5);
    }
    public static void b(){
        ApplicationContext bean = new ClassPathXmlApplicationContext("1022.xml");
        Object obj1 = bean.getBean("da");
        Object obj2 = bean.getBean("db");
        System.out.println(obj1);
        System.out.println(obj2);
    }
    public static void c(){
        ApplicationContext bean = new ClassPathXmlApplicationContext("1022.xml");
        org.example.pack1022.wan.DemoC da = bean.getBean(  org.example.pack1022.wan.DemoC.class);
        da.a();
    }
    public static void d(){
        ApplicationContext bean = new ClassPathXmlApplicationContext("1022.xml");
        UserCotroller uc = bean.getBean("userCotroller",UserCotroller.class);
        uc.a();
    }
    public static void work1022(){
        ApplicationContext bean = new ClassPathXmlApplicationContext("1022.xml");
        Object obj1 = bean.getBean("cl1");
        Object obj2 = bean.getBean("cl2");
        System.out.println(obj1);
        System.out.println(obj2);
    }
    public static void main( String[] args )
    {
        work1022();
    }
}
